
var numList = [];
var smallList = [];
var bigList = [];
var speList = ["_", "$","%","!"];
var allList = [];
var smallcode=[];

for(var i=97;i<123;i++){
    smallcode.push(i)
}

for (var i = 0; i <= 9; i++) {
    numList.push(String(i));  // 转成字符串
}

for (var i = 97; i <= 122; i++) {
    var code = String.fromCharCode(i);
    // console.log(code);
    smallList.push(code);
}

for (var i = 65; i <= 90; i++) {
    var code = String.fromCharCode(i);
    // console.log(code);
    bigList.push(code);
}
codeList=bigList.concat(smallList);
allList = numList.concat(smallList, bigList, speList);


var objUser=new Object;
function judgeUser(userName){
            if (userName != "") {
                if (userName.length >= 6 && userName.length <= 12) {
                    //   console.log(start);
                    if (!(numList.includes(userName.charAt(0)))) {
                        var flag = true;
                        for (var i = 0; i < userName.length; i++) {
                            if ((allList.includes(userName.charAt(i)) == false)) {
                                flag = false;
                            }
                        }
                        if (flag == false) {
                            objUser.text = "字符由数字，字母(大小写)，下划线，$ 组成";
                            objUser.color = "red";
                            objUser.size = "12px";
                            objUser.status=false;
                            return objUser;
                        }
                        else {
                            objUser.text = "输入正确";
                            objUser.size = "12px";
                            objUser.color = "green";
                            objUser.status=true;
                            return objUser;
                        }

                    }
                    else {
                        objUser.text = "第一个字符不能为数字";
                        objUser.color = "red";
                        objUser.size = "12px";
                        objUser.status=false;
                        return objUser;
                    }
                }
                else {
                    objUser.text = "用户名需要在6-12位之间";
                    objUser.color = "red";
                    objUser.size = "12px";
                    objUser.status=false;
                    return objUser;
                }
            }
            else {
                objUser.text = "用户名不能为空";
                objUser.color = "red";
                objUser.size = "12px";
                objUser.status=false;
                return objUser;
            }
}

var objPwd=new Object;
function judgePwd(_value){
    if (_value != "") {
        if (_value.length >= 6 && _value.length <= 12) {
            var flag = true;
            console.log()
            for (var i = 0; i < _value.length; i++) {
                if ((allList.includes(_value.charAt(i)) == false)) {
                    flag = false;
                }
            }
            if (flag == false) {
                objPwd.text = "不能含有特殊字符";
                objPwd.color = "red";
                objPwd.size = "12px";
                objPwd.status=false
                return objPwd
            }
            else {
                objPwd.text = "密码输入正确";
                objPwd.color="green";
                objPwd.size = "12px";
                objPwd.status=true;
                return objPwd
            }

        }
        else {
            objPwd.text = "密码需要在6-12位之间";
            objPwd.color = "red";
            objPwd.size = "12px";
            objPwd.status=false
            return objPwd
        }
    }
    else {
        objPwd.text = "密码不能为空";
        objPwd.color = "red";
        objPwd.size = "12px";
        objPwd.status=false
        return objPwd
    }
}
var objCode=new Object;
function judgeCode(_code){
    if (_code == code_a) {
        objCode.text = "输入正确";
        objCode.color="green";
        objCode.size = "12px"
        objCode.status=true;
        return objCode;
    }
    else {
        objCode.text = "输入有误";
        objCode.color = "red";
        objCode.size = "12px"
        objCode.status=false;
        return objCode;
    }

}

function click(_Oinp){
_Oinp.onclick=function(){
    _Oinp.value=""
}
}

